import java.util.Scanner;
public class Main{

	public static String isPrimer(int n){
		boolean flag=true;
		int p=(int)Math.sqrt(n);
		if(n==1) return "F";
		for(int i=2;i<=p;i++){
			if(n%i==0){
				flag=false;
				break;
			}
		}
		return flag?"T":"F";
	}

	public static int factSum(int n){
		if(n==0 || n==1) return 1;
		int[] a=new int[1000];
		int ap=1, i,j, w=0, x=100000;
		a[0]=1;
		int sum=0;
		for(i=2;i<=n;i++){
			w=0;
			for(j=0;j<ap;j++){
				a[j] *= i;
				a[j] += w;
				w = a[j] / x;
				a[j] %= x;
			}
			a[ap] +=w;
			if(a[ap]!=0)
				ap++;
		}
		/*
		// output:
		System.out.print(n+" "+a[ap-1]);
		for(i=ap-2;i>=0;i--)
			System.out.print(String.format("%05d",a[i]));
			*/
		for(i=ap-1;i>=0;i--){
			int temp=a[i];
			while(temp!=0){
				sum += temp % 10;
				temp /=10;
			}
		}
		return sum;
	}

	public static void main(String[] args){
		Scanner scanner=new Scanner(System.in);
		int n=scanner.nextInt();
		int temp=factSum(n);

		System.out.println(temp+isPrimer(temp));
		scanner.close();
	}
}